package com.beimihu.leetcode.基本算法;

public class BinarySearch {
    public static int binarySearchBasic(int[] a , int target){
        int i = 0 , j = a.length - 1;

        while ( i <= j){
            int m = (i + j) / 2;
            if(target < a[m]){
                j = m - 1;
            } else if (target > a[m]) {
                i = m + 1;
            } else if (target == a[m]) {
                return m;
            }
        }
        return -1;
    }
}
